package 循环语句作业;

import java.util.Scanner;

public class homemork1 {

    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.print("请输入一个正整数: ");
    int num = scanner.nextInt();
    int sum = 0;
    for (int i = 1; i <= num; i++) {
        sum += i;
    }
    System.out.println("1到" + num + "的和为: " + sum);
    scanner.close();
}
}

